package com.tgy.reflection;

/***
 * @ClassName: JavaMemory
 * @Description: 测试java内存机制
 * @Auther: 送一一块二向箔
 * @Date: 15:48 2021/12/1
 * @version : V1.0
 */
public class JavaMemory {
    public static void main(String[] args) {
        A a = new A();
        System.out.println(a.m);

        /*
          1、加载到内存，会产生一个类对应的Class对象
          2、链接，链接完成后 m =0
          3、初始化
                <clinit>(){
                    System.out.println("A类静态代码块初始化");
                    m = 300;
                    m = 100;
                }

        */
    }

}
class A{
    static {
        System.out.println("A类静态代码块初始化");
        m = 300;
    }
    static  int m = 100;

    public A() {
        System.out.println("A类的无参构造初始化");
    }
}
